package com.lqian.simplestructure.tree.binarytree;

import com.sun.org.apache.bcel.internal.generic.RETURN;

public class BinaryTree {
    Node root;

    public void setRoot(Node root) {
        this.root = root;
    }

    public Node getRoot() {
        return root;
    }


    //前序遍历
    public void frontShow() {
        if (root != null){
            root.frontShow();
        }

    }

    public void midShow() {
        if (root != null){
            root.midShow();
        }

    }

    public void afterShow() {
        if (root != null){
            root.afterShow();
        }

    }

    //前序查找
    public Node frontSearch(int value) {
        return root.frontSearch(value);
    }

    public Node midSearch(int value) {
        return root.midSearch(value);
    }

    public Node afterSearch(int value) {
        return root.afterSearch(value);
    }

    //删除一颗子树
    public void delete(int value) {
        if (root.value == value){
            root = null;
        }else {
            root.delete(value);
        }

    }
}
